﻿using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
namespace MenuGame2DXNA
{
    public abstract class VisibleGameEntity : GameEntity
    {
        protected int nObjectVisible;
        protected dynamic ObjectVisible;
        private Vector2 _TopLeft;

        public Vector2 TopLeft
        {
            get { return _TopLeft; }
            set 
            { 
                _TopLeft = value;
                UpdatePositon();
            }
        }
        private Vector2 positionStart;

        /// <summary>
        /// Gets or sets the position start.
        /// </summary>
        /// <value>
        /// The position start.
        /// </value>
        public Vector2 PositionStart
        {
            get { return positionStart; }
            set { 
                positionStart = value;
                UpdatePositon();
            }
        }
        virtual public void UpdatePositon()
        {
            for (int i = 0; i < nObjectVisible; i++)
            {
                ObjectVisible[i].Position =PositionStart + _TopLeft;
            }
        }

        private Vector2 _Size;

        public Vector2 Size
        {
            get { return _Size; }
            set { _Size = value; }
        }
        virtual public void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            for (int i = 0; i < nObjectVisible; i++)
            {
                ObjectVisible[i].Draw(gameTime,spriteBatch);
            }
        }

        virtual public void Update(GameTime gameTime, Color color)
        {
            for (int i = 0; i < nObjectVisible; i++)
            {
                ObjectVisible[i].Update(gameTime);
            }
        }
        virtual public bool IsClicked(Vector2 point)
        {
            if (point.X >= _TopLeft.X && point.X <= _TopLeft.X + _Size.X &&
                point.Y >= _TopLeft.Y && point.Y <= _TopLeft.Y + _Size.Y)
                return true;
            return false;
        } 


       
       
      

    }
}
